var ClubAssistantInviteWindow = Window.extend({
    _ccsFileName: res.ClubAssistantInviteWindow_json,
    _clubId: null,
    _tableViewList: [],
    initWindow: function (clubId,roomInfo) {
        this._clubId = clubId;
        this._roomInfo = roomInfo;
        this._initTableView();
        clubMsgManager.requestClubMember(clubId);
    },

    /**
     * 初始化TableView
     * @private
     */
    _initTableView: function () {
        var nodeContent = this._nodeList['nodeContent'];
        var tableViewSize = nodeContent.getContentSize();
        this._tableView = new cc.TableView(this, cc.size(tableViewSize.width, tableViewSize.height));
        this._tableView.setDelegate(this);
        this._tableView.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL);
        this._tableView.setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN);
        nodeContent.addChild(this._tableView);
    },

    /**
     * 监听亲友圈消息
     * @private
     */
    _initEventListeners: function () {
        this._eventListeners = {};
        this._eventListeners[ClubMsgCode.AllMemberInfo] = '_allMemberInfoHandler';
    },

    _allMemberInfoHandler: function () {
        var members = ClubDataManager.getClubMembers(this._clubId);
        this._tableViewList = [];
        for (var i = 0; i < members.length; i++) {
            if (members[i]['state'] == ClubDataManager.MemberState_OffLine) {
                continue;
            }
            this._tableViewList.push(members[i]);
        }

        this._tableViewList.sort(function (a, b) {
            if (a['black'] && !b['black']) {
                return 1;
            }
            if (a['state'] == ClubDataManager.MemberState_Room && b['state'] == ClubDataManager.MemberState_OnLine) {
                return 1;
            }
            return -1;
        });

        this._tableView.reloadData();
    },

    tableCellAtIndex: function (table, idx) {
        var cell = table.dequeueCell();
        var node = null;
        if (cell == null) {
            cell = new cc.TableViewCell();
            node = addItem('ClubAssistantInviteItem', cell, (idx + 1), this._tableViewList[idx], this._clubId,this._roomInfo);
            node.setName("itemCell");
        } else {
            node = cell.getChildByName("itemCell");
            node.setData((idx + 1), this._tableViewList[idx], this._clubId,this._roomInfo);
        }
        return cell;
    },
    tableCellTouched: function (table, cell) {
    },
    tableCellSizeForIndex: function (table, idx) {
        return cc.size(1163, 68);
    },
    numberOfCellsInTableView: function (table) {
        return this._tableViewList.length;
    },
});